//
//  BBFileTabView.m
//  xNose
//
//  Created by ben smith on 18/09/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "BBFileTabView.h"
#import "BBImageButtonFactory.h"
#import "BBAppController.h"

@implementation BBFileTabView
- (id)initWithFrame:(NSRect)frame {
	self = [super initWithFrame:frame];
	if (self) {
		// Initialization code here.
		// add the various views
		NSRect buttonRect = [self buttonRect];
		
		NSButton * button1 = [BBImageButtonFactory imageButtonInRect:buttonRect withImageName:@"one"];
		[button1 setTarget:self];
		[button1 setAction:@selector(oneClick)];
		[self addSubview:button1];
		
		buttonRect.origin.x += [self buttonBorder];
		
		NSButton * button2 = [BBImageButtonFactory imageButtonInRect:buttonRect withImageName:@"two"];
		[button2 setTarget:self];
		[button2 setAction:@selector(twoClick)];
		[self addSubview:button2];
		
		buttonRect.origin.x += [self buttonBorder];
		
		NSButton * button3 = [BBImageButtonFactory imageButtonInRect:buttonRect withImageName:@"three"];
		[button3 setTarget:self];
		[button3 setAction:@selector(threeClick)];
		[self addSubview:button3];
		
		// set the stuckout var so that the tab comes out far enough
		stuckOutX = stuckInX - (buttonRect.origin.x + 25);
	}
	return self;
}

-(void)oneClick
{
	NSString * filename = [[NSUserDefaults standardUserDefaults] objectForKey:@"BBScene1FileName"];
	if (![[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:NO]) return;
	[[BBAppController sharedAppController] loadFromFile:filename];
}

-(void)twoClick
{
	NSString * filename = [[NSUserDefaults standardUserDefaults] objectForKey:@"BBScene2FileName"];
	if (![[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:NO]) return;
	[[BBAppController sharedAppController] loadFromFile:filename];
}

-(void)threeClick
{
	NSString * filename = [[NSUserDefaults standardUserDefaults] objectForKey:@"BBScene3FileName"];
	if (![[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:NO]) return;
	[[BBAppController sharedAppController] loadFromFile:filename];
}


@end
